package com.stork.sms.adapter;



import com.stork.sms.R;

import android.app.Activity;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.TableRow.LayoutParams;

public class ExamListPagerAdapter extends PagerAdapter {

	
	View viewLayout,viewRow;
	Activity activity;
	int  size;
	TextView textDisplay;
	public TableLayout examlisttable;
	
	public ExamListPagerAdapter(Activity markList, int viewPagerSize ) {
		// TODO Auto-generated constructor stub		
		activity=markList;
		size=viewPagerSize;		
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return size;
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		// TODO Auto-generated method stub		
		return arg0==((View)arg1);
	}
	
	@Override
	public Object instantiateItem(View container, int position) {
		// TODO Auto-generated method stub
		
		 LayoutInflater inflater = (LayoutInflater) activity
	                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	      
		 viewLayout = inflater.inflate(R.layout.tablepageradapter, null);
	        viewRow=inflater.inflate(R.layout.head, null);
	        textDisplay = (TextView) viewLayout.findViewById(R.id.displaytextView1);
	        examlisttable=(TableLayout)viewLayout.findViewById(R.id.Mark_list);
	        int pageno=position+1;
	        textDisplay.setText("Now your in Page No  "+pageno);
	        
	        
	        TableRow Head =((TableRow)viewRow);
		    ((TextView)Head.findViewById(R.id.head)).setText("Selecteditem");
		    examlisttable.addView(Head,new TableLayout.LayoutParams(
	            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	        
	        ((ViewPager) container).addView(viewLayout, 0);
	        return viewLayout;
		}
	
	@Override
	public void destroyItem(View container, int position, Object object) {
		// TODO Auto-generated method stub
		((ViewPager)container).removeView((View)object);
	}
	
	}
